package com.satan.juc.demo13;

import java.util.concurrent.locks.LockSupport;

/**
 * @Author: Demon
 * @Date: 2024/3/29 16:55
 * @Description:与第五个例子类似，但增加了blocker对象。
 **/
public class ParkUntilWithBlockerDemo {
    public static void main(String[] args) {
        final Object blocker = new Object();
        Thread thread = new Thread(() -> {
            long deadline = System.currentTimeMillis() + 5000; // 2 seconds from now
            System.out.println("Thread is going to park with a blocker until the deadline.");
            LockSupport.parkUntil(blocker, deadline);
            System.out.println("Thread is unparked or the deadline has passed.");
        });

        thread.start();
    }
}
